import React from 'react'
import store from '../../store';
import {addAction, subAction, timesAction, asyncAddAction} from '../../store/reducers/countReducer';
import { increAction } from '../../store/reducers/zanReducer';

export default function ReduxCom() {
  console.log(store.getState());
  return (
    <div>
      <h2>{store.getState().count}</h2>
      <button onClick={() => {
        store.dispatch(addAction(20));
      }}>+20</button>
      <button onClick={() => {
        store.dispatch(subAction(15));
      }}>-15</button>
      <button onClick={() => {
        store.dispatch(timesAction(2));
      }}>*2</button>
      <button onClick={() => {
        store.dispatch(asyncAddAction(1));
      }}>1秒之后 +1</button>
      <hr />
      <h2>点赞数: {store.getState().zan}</h2>
      <button onClick={() => {
        store.dispatch(increAction(1));
      }}>点赞</button>
    </div>
  )
}
